package io.wins.vertx.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import io.wins.vertx.utils.UUIDUtils;
import org.apache.commons.lang3.StringUtils;

@DataObject(generateConverter = true)
public class CustomerAddress {
    private final String id;
    private String parentId;
    private String receiver;
    private String phone;
    private String postcode;
    private boolean isDefault;
    private String areaCode;
    private String areaName;
    private String detail;

    public CustomerAddress(final JsonObject json) {
        CustomerAddressConverter.fromJson(json, this);
        this.id = StringUtils.isEmpty(json.getString("id")) ?
            UUIDUtils.genId() : json.getString("id");
    }

    public JsonObject toJson() {
        final JsonObject json = new JsonObject();
        CustomerAddressConverter.toJson(this, json);
        return json;
    }


    public String getId() {
        return this.id;
    }

    public String getParentId() {
        return this.parentId;
    }

    public void setParentId(final String parentId) {
        this.parentId = parentId;
    }

    public String getReceiver() {
        return this.receiver;
    }

    public void setReceiver(final String receiver) {
        this.receiver = receiver;
    }

    public String getPhone() {
        return this.phone;
    }

    public void setPhone(final String phone) {
        this.phone = phone;
    }

    public String getPostcode() {
        return this.postcode;
    }

    public void setPostcode(final String postcode) {
        this.postcode = postcode;
    }

    public boolean isDefault() {
        return this.isDefault;
    }

    public void setDefault(final boolean aDefault) {
        this.isDefault = aDefault;
    }

    public String getAreaCode() {
        return this.areaCode;
    }

    public void setAreaCode(final String areaCode) {
        this.areaCode = areaCode;
    }

    public String getAreaName() {
        return this.areaName;
    }

    public void setAreaName(final String areaName) {
        this.areaName = areaName;
    }

    public String getDetail() {
        return this.detail;
    }

    public void setDetail(final String detail) {
        this.detail = detail;
    }
}
